import type { AddressParams, AddressItem } from "@/types/address"
import { getAction, postAction, putAction, deleteAction } from "@/utils/http"

// 地址新增修改页保存地址接口
export const saveAddressApi = (data:AddressParams)=>{
    return postAction({
        url: '/member/address',
        data
    })
}

// 地址管理模块地址列表数据请求
export const getAddressListApi = ()=>{
    return getAction<AddressItem[]>({
        url: '/member/address'
    })
}

// 地址修改页详情数据获取接口
export const getAddressDetailApi = (id: string)=>{
    return getAction<AddressItem>({
        url: `/member/address/${id}`
    })
}


// 地址修改页修改更新数据接口
export const updateAddressDetailApi = (id: string, data: AddressParams)=>{
    return putAction<AddressItem>({
        url: `/member/address/${id}`,
        data
    })
}

// 地址列表页删除收货地址接口
export const deleteAddressApi = (id: string)=>{
    return deleteAction({
        url: `/member/address/${id}`
    })
}